package com.wenli.graduate2022.wenliGreenShop.service.servImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wenli.graduate2022.wenliGreenShop.entity.Address;
import com.wenli.graduate2022.wenliGreenShop.entity.User;
import com.wenli.graduate2022.wenliGreenShop.repository.mapper.AddressMapper;
import com.wenli.graduate2022.wenliGreenShop.repository.mapper.UserMapper;
import com.wenli.graduate2022.wenliGreenShop.service.servDao.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 真正的业务调用方法
 * @author HuangHai
 * @date 2021/9/26 20:47
 */
@Service
public class UserServImpl implements UserService {

    @Autowired
    private UserMapper userMapper;      //自动填充已经实现的类实例


    @Override
    public User login(String name, String password) {    //登录
        return userMapper.findByPassword(name,password);
    }

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public IPage<User> findByPage(Page page) {
        return userMapper.findByPage(page);
    }

    @Override
    public IPage<User> findByName(Page page,String name) {
        return userMapper.findByName(page,name);
    }

    @Override
    public User findById(Integer id) {
        return userMapper.findById(id);
    }

    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int update(User user) {
        return userMapper.update(user);
    }

    @Override
    public int initPassword(Integer id) {
        return userMapper.initPassword(id);
    }

    @Override
    public int delete(Integer id) {
        return userMapper.delete(id);
    }

    @Override
    public int updatePassword(User user, Integer id, String password) {
        return userMapper.updatePassword(user,id,password);
    }


}
